package com.example.kotlinstudy.基本语法

//fun com.example.kotlinstudy.类与对象.main() {
//    println("max of 0 and 42 is ${maxOf(0, 1)}")
//}
//fun maxOf(a: Int, b: Int) = if (a > b) a else b

//fun com.example.kotlinstudy.类与对象.main() {
//    val items = listOf("apple", "banana", "kiwifruit")
//    for (item in items) {
//        println(item)
//    }
//    for (index in items.indices) {
//        println("item at $index is ${items[index]}")
//    }
//    var index = 0
//    while (index < items.size) {
//        println("item at $index is ${items[index]}")
//        index++
//    }
//}

//fun describe(obj: Any): String =
//    when (obj) {
//        1 -> "One"
//        "Hello" -> "Greeting"
//        is Long -> "Long"
//        !is String -> "Not a string"
//        else -> "Unknown"
//    }
//fun com.example.kotlinstudy.类与对象.main() {
//    println(describe(1))
//    println(describe("Hello"))
//    println(describe(1000L))
//    println(describe(2))
//    println(describe("other"))
//}

fun main() {
//    val x = 10
//    val y = 9
//    //in监测数字是否在执行区域内
//    if(x in 1..y+1) {
//        println("fits in range")
//    }
//
//    val list = listOf("a", "b", "c")
//    if(-1 !in 0..list.lastIndex) {
//        println("-1 is out of range")
//    }
//    if(list.size !in list.indices) {
//        println("list size is out of valid list indices range, too")
//    }
    for (x in 1..5) {
        print(x)
    }
    println()
    for (x in 1..10 step 2) {
        print(x)
    }
    println()
    for (x in 9 downTo 0 step 3) {
        print(x)
    }
}